﻿using STT.Business;
using STT.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace STT.Admin.UserControls
{
    public partial class ucTimKiemHocVien : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                Methods.ChucVu(ref ddChucVu);
                Methods.ChuyenMon(ref ddChuyenMon);
                Methods.DonVi(ref ddDonVi);
                Methods.NgoaiNgu(ref ddTrinhDoNgoaiNgu);
                Methods.MonHoc(ref ddMonHoc);
                Methods.Lop(ref ddLopHoc);
                Methods.HocVan(ref ddHocVan);
        }

        protected void lbXuatDuLieu_Click(object sender, EventArgs e)
        {

        }

        protected void btTimKiem_Click(object sender, EventArgs e)
        {
            LoadDuLieu();
        }

        void LoadDuLieu()
        {
            gvHocVien.DataSource = BTbHocVien.SelectStudentsBySearch(new ETbHocVien
            {
                MaHV = txtMaHocVien.Text != "" ? txtMaHocVien.Text : "-1",
                TenHV = txtTenHocVien.Text,
                MaDonVi = int.Parse(ddDonVi.SelectedValue.ToString()),
                MaChucVu = int.Parse(ddChucVu.SelectedValue.ToString()),
                MaTDChuyenMon = int.Parse(ddChuyenMon.SelectedValue.ToString()),
                MaTDHocVan = int.Parse(ddHocVan.SelectedValue.ToString()),
            }, int.Parse(ddMonHoc.SelectedValue.ToString()),
            txtSoKhoaHoc.Text != "" ? int.Parse(txtSoKhoaHoc.Text) : -1,
            int.Parse(ddTrinhDoNgoaiNgu.SelectedValue.ToString()),
            int.Parse(ddLopHoc.SelectedValue.ToString())
            );
            gvHocVien.DataBind();
        }

        protected void gvHocVien_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvHocVien.SelectedIndex = e.NewPageIndex;
            LoadDuLieu();
        }
    }
}